Skip to content

plot_forecast


method plot_forecast(models=None, fh="test", X=None, target=0, plot_interval=True, title=None, legend="upper left", figsize=(900, 600), filename=None, display=True)[source]
Plot a time series with model forecasts.

This plot is only available for forecasting tasks.

Parametersmodels: int, str, Model, slice, sequence or None, default=None
Models to plot. If None, all models are selected. If no models are selected, only the target column is plotted.

fh: int, str, range, sequence or ForecastingHorizon, default="test"
Forecast horizon for which to plot the predictions. If string, choose from: "train", "test" or "holdout". Use a sequence or add + between options to select more than one.

X: dataframe-like or None, default=None
Exogenous time series corresponding to fh. This parameter is ignored if fh is a data set.

target: int or str, default=0
Target column to look at. Only for multivariate tasks.

plot_interval: bool, default=True
Whether to plot prediction intervals instead of the exact prediction values. If True, the plotted estimators should have a predict_interval method.

title: str, dict or None, default=None
Title for the plot.

legend: str, dict or None, default="upper left"
Legend for the plot. See the user guide for an extended description of the choices.

  • If None: No legend is shown.
  • If str: Location where to show the legend.
  • If dict: Legend configuration.

figsize: tuple, default=(900, 600)
Figure's size in pixels, format as (x, y).

filename: str or None, default=None
Save the plot using this name. Use "auto" for automatic naming. The type of the file depends on the provided name (.html, .png, .pdf, etc...). If filename has no file type, the plot is saved as html. If None, the plot is not saved.

display: bool or None, default=True
Whether to render the plot. If None, it returns the figure.

Returnsgo.Figure or None
Plot object. Only returned if display=None.


See Also

plot_lift

Plot the lift curve.

plot_prc

Plot the precision-recall curve.

plot_roc

Plot the Receiver Operating Characteristics curve.


Example

>>> from atom import ATOMForecaster
>>> from sktime.datasets import load_airline

>>> y = load_airline()

>>> atom = ATOMForecaster(y, random_state=1)
>>> atom.plot_forecast()

>>> atom.run(
...     models="arima",
...     est_params={"order": (1, 1, 0), "seasonal_order": (0, 1, 0, 12)},
... )
>>> atom.plot_forecast()

>>> atom.plot_forecast(fh="train+test", plot_interval=False)

>>> # Forecast the next 4 years starting from the test set
>>> atom.plot_forecast(fh=range(1, 48))